<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            给定一个字符串，请返回满足以下条件的最长字符串的长度：“a”、"b"、“c”、“x”、"y"、“z”在字符串中都恰好出现了偶数次（0也是偶数）
        */
        /* 
            输入例子1:
            amabc
            输出例子1:
            3
            例子说明1:
            ama，长度为3
        */
        let con = ['a', 'b', 'c', 'x', 'y', 'z'];
        let str = "amabc";
        let even = [];
        let arr = str.split("");
        for(let i = 0; i < con.length; i++){
            let count = 0;
            let index;
            let j;
            for (j = 0; j < arr.length; j++){
                if (arr[j] == con[i]){
                    // console.log(arr[j]);
                    count++;
                } 
                if (count % 2 == 0) {
                    even.push(arr[j]);
                }
                
            }
        }
        console.log(even);
    </script>
</body>

</html>